package com.jic.product.controller.manage;

import com.jic.common.base.vo.RestResult;
import com.jic.product.entity.ProductDescribe;
import com.jic.product.service.ProductDescribeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by WS on 2020/2/7  10: 55
 * 商品描述
 */
@RestController
@RequestMapping("/productDescribe")
@Api(value = "商品描述", tags = {"商品描述"})
public class ProductDescribeController {

    @Autowired
    ProductDescribeService productDescribeService;

    /*
     *  商品描述查询
     *
     * */
    @ApiOperation(value = "商品描述信息条件查询")
    @ResponseBody
    @PostMapping(value = "/queryProductDescribe")
    public RestResult<List<ProductDescribe>> query(@RequestBody ProductDescribe describe) {
        List<ProductDescribe> productDescribe = new ArrayList<>();
        try {
            productDescribe = productDescribeService.query(describe);
        } catch (Exception e) {
            e.printStackTrace();
            return RestResult.error("9999", e.getLocalizedMessage());
        }
        return RestResult.success(productDescribe);
    }

    /*
     *  商品描述信息修改
     *
     * */
    @ApiOperation(value = "商品描述信息修改")
    @ResponseBody
    @PostMapping(value = "/updateProductDescribe")
    public RestResult updateProductDescribe(ProductDescribe productDescribe) {
        return RestResult.success( productDescribeService.update(productDescribe));
    }

}
